package com.cter.thinkingInSpringBoot.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cter.thinkingInSpringBoot.route.BookInfoRoute;
import com.cter.thinkingInSpringBoot.to.BookTO;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@RequestMapping(BookInfoRoute.VERSION+BookInfoRoute.BOOKINFOBASE)
public class BookController {
	
	@ApiOperation(value = "查询图书列表",notes="查询图书的列表",httpMethod="GET")
	@GetMapping(BookInfoRoute.BOOKS)
	public String books() {
		return "《田园交响曲》";
	}
	
	
    @ApiOperation(value = "添加图书", notes = "添加新的图书",httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "书名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "author", value = "作者", required = true, dataType = "String")          
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功")
    })
    @PostMapping
    public String saveBook(@RequestBody BookTO bookto){
      return "ok";
    }
}
